<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get Documents by their Ids. Utilizes Solr Realtime Get (RTG)</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="solrclient.getbyid.html">« SolrClient::getById</a></li>
      <li style="float: right;"><a href="solrclient.getdebug.html">SolrClient::getDebug »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.solrclient.html">SolrClient</a></li>
    <li>Get Documents by their Ids. Utilizes Solr Realtime Get (RTG)</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="solrclient.getbyids" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SolrClient::getByIds</h1>
  <p class="verinfo">(PECL solr &gt;= 2.2.0)</p><p class="refpurpose"><span class="refname">SolrClient::getByIds</span> &mdash; <span class="dc-title">Get Documents by their Ids. Utilizes Solr Realtime Get (RTG)</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-solrclient.getbyids-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>SolrClient::getByIds</strong></span>(<span class="methodparam"><span class="type">array</span> <code class="parameter">$ids</code></span>): <span class="type"><a href="class.solrqueryresponse.html" class="type SolrQueryResponse">SolrQueryResponse</a></span></div>

  <p class="para rdfs-comment">
    Get Documents by their Ids. Utilizes Solr Realtime Get (RTG).
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-solrclient.getbyids-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">ids</code></dt>

    <dd>

     <p class="para">
      Document ids
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-solrclient.getbyids-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   <span class="type"><a href="class.solrqueryresponse.html" class="type SolrQueryResponse">SolrQueryResponse</a></span>
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-solrclient.getbyids-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-4641">
   <p><strong>示例 #1 <span class="function"><strong>SolrClient::getByIds()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">include&nbsp;</span><span style="color: #DD0000">"bootstrap.php"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$options&nbsp;</span><span style="color: #007700">=&nbsp;array<br />(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'hostname'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">SOLR_SERVER_HOSTNAME</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'login'&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">SOLR_SERVER_USERNAME</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'password'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">SOLR_SERVER_PASSWORD</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'port'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">SOLR_SERVER_PORT</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'path'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">SOLR_SERVER_PATH<br /></span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$client&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SolrClient</span><span style="color: #007700">(</span><span style="color: #0000BB">$options</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$response&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$client</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getByIds</span><span style="color: #007700">([</span><span style="color: #DD0000">'GB18030TEST'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'6H500F0'</span><span style="color: #007700">]);<br /><br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$response</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getResponse</span><span style="color: #007700">());<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
SolrObject Object
(
    [response] =&gt; SolrObject Object
        (
            [numFound] =&gt; 2
            [start] =&gt; 0
            [docs] =&gt; Array
                (
                    [0] =&gt; SolrObject Object
                        (
                            [id] =&gt; GB18030TEST
                            [name] =&gt; Array
                                (
                                    [0] =&gt; Test with some GB18030 encoded characters
                                )

                            [features] =&gt; Array
                                (
                                    [0] =&gt; No accents here
                                    [1] =&gt; 这是一个功能
                                    [2] =&gt; This is a feature (translated)
                                    [3] =&gt; 这份文件是很有光泽
                                    [4] =&gt; This document is very shiny (translated)
                                )

                            [price] =&gt; Array
                                (
                                    [0] =&gt; 0
                                )

                            [inStock] =&gt; Array
                                (
                                    [0] =&gt; 1
                                )

                            [_version_] =&gt; 1510294336239042560
                        )

                    [1] =&gt; SolrObject Object
                        (
                            [id] =&gt; 6H500F0
                            [name] =&gt; Array
                                (
                                    [0] =&gt; Maxtor DiamondMax 11 - hard drive - 500 GB - SATA-300
                                )

                            [manu] =&gt; Array
                                (
                                    [0] =&gt; Maxtor Corp.
                                )

                            [manu_id_s] =&gt; maxtor
                            [cat] =&gt; Array
                                (
                                    [0] =&gt; electronics
                                    [1] =&gt; hard drive
                                )

                            [features] =&gt; Array
                                (
                                    [0] =&gt; SATA 3.0Gb/s, NCQ
                                    [1] =&gt; 8.5ms seek
                                    [2] =&gt; 16MB cache
                                )

                            [price] =&gt; Array
                                (
                                    [0] =&gt; 350
                                )

                            [popularity] =&gt; Array
                                (
                                    [0] =&gt; 6
                                )

                            [inStock] =&gt; Array
                                (
                                    [0] =&gt; 1
                                )

                            [store] =&gt; Array
                                (
                                    [0] =&gt; 45.17614,-93.87341
                                )

                            [manufacturedate_dt] =&gt; 2006-02-13T15:26:37Z
                            [_version_] =&gt; 1510294336449806336
                        )

                )

        )

)
</pre></div>
   </div>
  </div>
 </div>



 <div class="refsect1 seealso" id="refsect1-solrclient.getbyids-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="methodname"><a href="solrclient.getbyid.html" class="methodname" rel="rdfs-seeAlso">SolrClient::getById()</a> - Get Document By Id. Utilizes Solr Realtime Get (RTG)</span></li>
  </ul>
 </div>


</div></div></div></body></html>